//
// Created by shen on 2024/12/20.
//

#ifndef AEDIT_SAFEQUEUE_H
#define AEDIT_SAFEQUEUE_H
#include "FFStatus.h"
#include "log.h"
extern "C"{
#include "libavcodec/avcodec.h"
};
#include "queue"
#include "mutex"

class SafeQueue {
public:
    SafeQueue(FFStatus *playerStatus1);
    ~SafeQueue();

    int putAvPacket(AVPacket *avPacket);
    int getAvPacket(AVPacket *avPacket);
    int getQueueSize();
    void clearAvPacket();
    void noticeQueue();
    void clearByBeforeTime(int64_t time,AVRational time_base);
    double getMaxPts();

public:
    std::queue<AVPacket *> queuePacket;
    pthread_cond_t condPacket;
    pthread_mutex_t mutexPacket;
    FFStatus *playerStatus = NULL;
};


#endif //AEDIT_SAFEQUEUE_H
